<#compress>

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,  user-scalable=0;" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style"  />
    <meta content="telephone=no" name="format-detection" />

    <link href="${ctx}/static/mobileweb/scripts/photoswipe/photoswipe.css" type="text/css" rel="stylesheet"/>
    <link href="${ctx}/static/mobileweb/css/replay.css" type="text/css" rel="stylesheet"/>
    <style type="text/css">
        div.fl a { display: inline-block; text-align: center; line-height: 200%; -webkit-border-radius: 31px; -moz-border-radius: 31px; border-radius: 31px; -webkit-background-clip: padding-box; -moz-background-clip: padding-box; background-clip: padding-box; font-size: 0;}
        div.fl a img{ -webkit-border-radius : 31px; -moz-border-radius : 5px;border:1.5px solid #fdaa62; border-radius:5px; width : 62px; height : 62px; }
    </style>

    <link rel="stylesheet" href="${ctx}/static/mobileweb/1/css/common_ba.css?_=${.now?string('yyyy-MM-dd')}">

    <title>品牌活动</title>
</head>
<body>
<section>
    <input type="hidden" name="mid" id="mid" value="${mid}"/>
    <input type="hidden" name="wxno" id="wxno" value="${wxno}"/>

    <div class="mb10"><img src="${ctx}/static/mobileweb/1/images/advimg02_02.jpg" class="wdh100"/></div>
    <div class="shareBox fdshareBox">
    <#if list?? && list?size gt 0>
        <#list list as a>
            <div class="sharelist fdsharelist">
                <div class="fl">
                    <a href="${ctx}/mobileweb/brand/showbrand?id=${a.brand!}&mid=${mid}&wxno=${wxno}">
                        <#if a.logo??>
                            <img src="${ctx}/${a.logo!}"/>
                        <#else>
                            <img src="${ctx}/static/mobileweb/images/logo.png"/>
                        </#if>
                    </a>
                </div>
                <div class="fr">
                    <div class="title" id="title_${a.activity!}">${a.name!}</div>
                    <div class="mb10 fs90 desc" id="description_${a.activity!}">${a.description!}</div>
                    <p class="dishlinks activity_picture">
                        <#if a.picture??>
                            <#list a.picture?split(',') as s>
                                <#if s?? && s != ''>
                                <a href="${ctx}/${s!}"><img src="${ctx}${s!}"/></a>
                                </#if>
                            </#list>
                        </#if>
                    </p>
                    <div class="clearfix">
                        <span class="time fs80"><@prettyTime time="${a.create_time?string('yyyy-MM-dd HH:mm:ss')}"></@prettyTime></span>
	               <span class="personview" id="personview">
	                  <a href="javascript:void(0)" class="tips"><img src="${ctx}/static/mobileweb/1/images/tips.png"/></a>
		                <span class="tipshow" <#if a.likeId??>style="min-width: 208px;"<#else>style="min-width: 199px;"</#if>>
			                 <a href="${ctx}/mobileweb/brand/activityInfo?activity=${a.activity!}&mid=${mid!}&wxno=${wxno!}" title="分享"
                                name="share" brand="${a.brand!}" activity="${a.activity!}" imgUrl="${a.picture!}"><i class="sharesIcon"></i>分享</a>
			                 <a href="javascript:void(0)" name="like" brand="${a.brand!}" activity="${a.activity!}" likeId="${a.likeId!}">
                                 <i class="likeIcon"></i><span><#if a.likeId??>取消<#else>赞&nbsp;</#if></span>
                             </a>
			                 <a href="javascript:void(0)" <#if a.reply?? && a.reply>name="comment" <#else>style="color: #9C9C9B;"</#if> data-brand="${a.brand!}" data-activity="${a.activity!}"><i class="reviewIcon"></i>评论 </a>
		                </span>
	               </span>
                    <span id="commentshow-${a.activity!}" name="commentshow" data-brand="${a.brand!}" data-activity="${a.activity!}">
                        <#--<div class="commentshow" >
                            <i class="arrowt"></i>
                            <p><img src="${ctx}/static/mobileweb/1/images/likegray.png" class="vermid"/> GD</p>
                            <p><span class="name">GD:</span>好好吃的样子</p>
                            <p><span class="name">TOP:</span>美味</p>
                            <p><span class="name">GD:</span>口水</p>
                        </div>-->
                    </span>
                    </div>
                </div>
                <br class="cb"/>
            </div>
        </#list>
    </#if>
</section>

<script id="tmpl_noshow" type="text/html">
    <div class="commentshow" >
        <i class="arrowt"></i>
        <p><img src="${ctx}/static/mobileweb/1/images/likegray.png" class="vermid"/> (<span name="count">1</span>)</p>
    </div>
</script>

<script id="tmpl_noshowcontent" type="text/html">
    <div class="commentshow" >
        <i class="arrowt"></i>
        <p><img src="${ctx}/static/mobileweb/1/images/comavatar.png" class="vermid"/> {{content}}</p>
    </div>
</script>
<script id="tmpl_showcomment" type="text/html">
    <p><img src="${ctx}/static/mobileweb/1/images/comavatar.png" class="vermid"/> {{content}}</p>
</script>

<script id="tmpl_showlike" type="text/html">
    <p><img src="${ctx}/static/mobileweb/1/images/likegray.png" class="vermid"/> (<span name="count">1</span>)</p>
</script>

<script id="tmpl_replyForm" type="text/html">
    <div class="popLayer" style="width:86%" id="{{id}}">
        <form method="post" action="${ctx}/mobileweb/brand/activityReply" id="replyForm">
            <input type="hidden" name="mid" value="${mid!}">
            <input type="hidden" name="wxno" value="${wxno!}">
            <input type="hidden" name="brand" value="{{brand}}">
            <input type="hidden" name="activity" value="{{activity}}">

            <div class="sendBorder">
                <textarea id="content" name="content" cols="" rows="" class="sInput" placeholder="回两句吧..."></textarea>
            </div>
            <div class="sendOperate">
                <div class="operBtn db fr">
                    <a href="javascript:;" id="cBtn" class="cancelBtn db close" title="">取消</a>
                    <a href="javascript:;" id="comBtn" class="sendBtn c1 db" title="">发送</a>
                    </span>
                </div>
        </form>
    </div>
</script>

</body>
<script type="text/javascript" src="${ctx}/static/mobileweb/scripts/jquery-1.7.2.min.js"></script>



<script charset="utf-8" src="${ctx}/static/scripts/handlebars.js"></script>
<script charset="utf-8" src="${ctx}/static/scripts/plugins/jquery-form/jquery.form.js"></script>
<script type="text/javascript" src="${ctx}/static/mobileweb/scripts/reply/global.js"></script>

<script type="text/javascript" src="${ctx}/static/mobileweb/scripts/photoswipe/simple-inheritance.min.js"></script>
<script type="text/javascript" src="${ctx}/static/mobileweb/scripts/photoswipe/jquery.animate-enhanced.min.js"></script>

<script type="text/javascript" src="${ctx}/static/mobileweb/scripts/photoswipe/code-photoswipe-1.0.11.min.js"></script>

<script>

    $(function(){

        $('span[name="commentshow"]').each(function() {
            var _this = this;
            var brand = $(_this).attr("data-brand");
            var activity = $(_this).attr("data-activity");

            $.post("${ctx}/mobileweb/brand/loadCommentAndLike", {brand : brand, activity: activity}, function(rets) {
                if (rets) {
                    $(_this).html(rets);
                }
            });
        });

        var source   = $("#tmpl_replyForm").html();
        var tmpl_noshow = $('#tmpl_noshow').html();
        var tmpl_showlike = $('#tmpl_showlike').html();

        var tmpl_noshowcontent = $('#tmpl_noshowcontent').html();
        var tmpl_showcomment = $('#tmpl_showcomment').html();

        $('.personview .tips').click(function(){
            var tipbox = $(this).next('.tipshow');
            if(tipbox.is(':hidden')){
                tipbox.show(100);
                tipbox.parents('.fdsharelist').siblings().find('.tipshow').hide(100);
            }else{
                tipbox.hide(100);
            }
        });

        $(document).bind('click',function(e){
            var $target = $(e.target);
            var tipbox = $('.personview .tipshow');
            var tips = $('.personview .tips');
            if(!$target.closest(tipbox) && !$target.closest(tips)){
                tipbox.stop().hide();
            }
        });

        $(".activity_picture a").photoSwipe();

        var mid = $("#mid").val();
        var wxno = $("#wxno").val();
        if (mid) {
            $("a[name='share']").click(function () {
                var _this = this;
                var brand = $(_this).attr("brand");
                var activity = $(_this).attr("activity");

                var isTrue = false;

                $.ajax({
                    method : 'POST',
                    url    : '${ctx}/mobileweb/brand/activityShare',
                    async  : false,
                    data   : {mid: mid, wxno: wxno, brand: brand, activity: activity},
                    success: function (msg) {
                        if (msg.status == 'OK') {
                            /*$(_this).find("img").attr('src', has_share_img);
                            $(_this).attr("name", "");*/
                            isTrue = true;
                        }
                    }
                });
                return isTrue;
            });
            $("a[name='like']").click(function () {
                var _this = this;
                var likeId = $(_this).attr("likeId");
                var brand = $(_this).attr("brand");
                var activity = $(_this).attr("activity");

                if(!likeId) { //喜欢
                    $.post('${ctx}/mobileweb/brand/activityLike', {mid: mid, wxno: wxno, brand: brand, activity: activity}, function (msg) {
                        if (msg.status == 'OK') {
                            $(_this).attr("likeId", msg.data);
                            //showTipElement($(_this), " +1 ");
                            $(_this).closest('.tipshow').css({'min-width':'208px'}).hide(100);
                            $(_this).find("span").html("取消");
                            var $area = $('#commentshow-' + activity);
                            var $show = $area.find('.commentshow');
                            //HTML内容显示处理
                            if (!$show || $show.length == 0) {
                                $area.html(tmpl_noshow);
                            } else {
                                var $like = $show.find('span[name="count"]');
                                if (!$like || $like.length == 0) {
                                    $area.find('.arrowt').after(tmpl_showlike);
                                } else {
                                    $like.html(parseInt($like.html()) + 1);
                                }
                            }
                        }
                    });
                } else {
                    $.post('${ctx}/mobileweb/brand/unActivityLike', {likeId: likeId}, function (msg) {
                        if (msg.status == 'OK') {
                            $(_this).attr("likeId", "");
                            //showTipElement($(_this), " -1 ");
                            $(_this).closest('.tipshow').css({'min-width':'199px'}).hide(100);
                            $(_this).find("span").html("赞");
                            var $area = $('#commentshow-' + activity);
                            var $show = $area.find('.commentshow');
                            //HTML内容显示处理
                            var $like = $show.find('span[name="count"]');
                            var curNum = parseInt($like.html());
                            var $commentareas = $show.find('p[name="comment-area"]');
                            if (curNum == 1) {
                                $like.parent().remove();
                                if (!$commentareas || $commentareas.length == 0) {
                                    $show.remove();
                                }
                            } else {
                                $like.html(curNum - 1);
                            }
                        }
                    });
                }
            });

            $('a[name="comment"]').click(function() {
                var _this = this;
                var brand = $(_this).attr("data-brand");
                var activity = $(_this).attr("data-activity");
                reply(brand, activity, source, function(re) {
                    if (re.status == 'OK') {
                        var $area = $('#commentshow-' + activity);
                        var $show = $area.find('.commentshow');

                        if (!$show || $show.length == 0) {
                            var tampa = Handlebars.compile(tmpl_noshowcontent);
                            $area.html(tampa({content : re.data}));
                        } else {
                            var tampa = Handlebars.compile(tmpl_showcomment);
                            $show.append(tampa({content : re.data}))
                        }
                    }
                });

                $(_this).closest('.tipshow').hide(100);
            });
        }

    });


</script>

</html>

</#compress>